package main

import (
	"fmt"

	"github.com/yourusername/gox"
	"strings"
)

func main() {
	id := 123
	status := "active"

	fmt.Println("=== 复杂嵌套 ${} 语法演示 ===")

	// 你的复杂嵌套语法示例
	query := func() *gox.Sql {
		__gox_sql_0_builder := gox.NewSqlBuilder()
		__gox_sql_0_builder.AddText(" SELECT * FROM users WHERE 1 = 1 ")
		if __result := func() (__result interface{}) {
			if id > 0 {
				func() string {
					var __parts []string
					__parts = append(__parts, "AND id > #{id}")
					if __codeResult := func() string {

						if status == "active" {
							return "AND status = #{status}"
						}

						return ""
					}(); __codeResult != "" {
						__parts = append(__parts, __codeResult)
					}
					return strings.Join(__parts, " ")
				}()
			}
			return __result
		}(); __result != nil {
			__gox_sql_0_builder.AddText(fmt.Sprintf("%v", __result))
		}
		__gox_sql_0 := __gox_sql_0_builder.Build()
		return __gox_sql_0
	}()

	fmt.Println("Query:", query.String())
	fmt.Println("Generated successfully!")
}
